class Solution {
public:
    string addBinary(string a, string b) {
        int cur1=a.size()-1,cur2=b.size()-1,t=0;
        string ret;
        while(cur1>=0||cur2>=0||t!=0)
        {
            if(cur1>=0)t+=a[cur1--]-'0';
            if(cur2>=0)t+=b[cur2--]-'0';
            ret+=t%2+'0';
            t/=2;
        }
        reverse(ret.begin(),ret.end());
        return ret;
    }
};
